home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PASCALL / NEETVGA / RGB / FSUPVGA.PAS < prev    next >
Pascal/Delphi Source File  |  1993-03-02  |  3KB  |  93 lines

  1. unit fsupvga;
  2.  
  3. interface
  4. var
  5. {  GraphDriver : integer;   The Graphics device driver }
  6. {  GraphMode   : integer;   The Graphics mode value }
  7.   MaxX, MaxY  : word;     { The maximum resolution of the screen }
  8.   ErrorCode   : integer;  { Reports any graphics errors }
  9.   MaxColor    : word;     { The maximum color value available }
  10.  
  11. procedure Initializesupvga(graphmode:integer; pathtodriver:string);
  12.  
  13.  
  14.  
  15. implementation
  16. uses
  17.    crt,graph;
  18. var
  19.   OldExitProc : Pointer;  { Saves exit procedure address }
  20.   graphicmode : ^integer;
  21.  
  22. {$F+}
  23. procedure MyExitProc;
  24. begin
  25.   ExitProc := OldExitProc; { Restore exit procedure address }
  26. {  CloseGraph;}              { Shut down the graphics system }
  27.   restorecrtmode;
  28. end; { MyExitProc }
  29. {$F-}
  30.  
  31. {$F+}
  32. function DetectVGA256 : integer;
  33. { Detects VGA or MCGA video cards }
  34. var
  35.   DetectedDriver : integer;
  36.   SuggestedMode  : integer;
  37. begin
  38.   DetectGraph(DetectedDriver, SuggestedMode);
  39.   if (DetectedDriver = VGA) or (DetectedDriver = MCGA) then
  40.     DetectVGA256 := graphicmode^        { Default video mode = 0 }
  41.   else
  42.     DetectVGA256 := grError; { Couldn't detect hardware }
  43. end; { DetectVGA256 }
  44. {$F-}
  45.  
  46.  
  47. procedure Initializesupvga(graphmode:integer; pathtodriver:string);
  48. { Initialize graphics and report any errors that may occur }
  49. var
  50.   graphdriver:integer;
  51.   InGraphicsMode : boolean; { Flags initialization of graphics mode }
  52. {  PathToDriver   : string;   Stores the DOS path to *.BGI & *.CHR }
  53.   AutoDetectPointer : pointer;
  54. begin
  55.   { when using Crt and graphics, turn off Crt's memory-mapped writes }
  56.   graphicmode^:=graphmode;
  57.   DirectVideo := False;
  58.   OldExitProc := ExitProc;                { save previous exit proc }
  59.   ExitProc := @MyExitProc;                { insert our exit proc in chain }
  60. {  PathToDriver := '';}
  61.   repeat
  62.  
  63.     AutoDetectPointer := @DetectVGA256;   { Point to detection routine }
  64.     GraphDriver := InstallUserDriver('SVGA256', AutoDetectPointer);
  65.     GraphDriver := Detect;
  66.  
  67.     InitGraph(GraphDriver, GraphMode, PathToDriver);
  68.     ErrorCode := GraphResult;             { preserve error return }
  69.     if ErrorCode <> grOK then             { error? }
  70.     begin
  71.       Writeln('Graphics error: ', GraphErrorMsg(ErrorCode));
  72.       if ErrorCode = grFileNotFound then  { Can't find driver file }
  73.       begin
  74.         Writeln('Enter full path to BGI driver or type <Ctrl-Break> to quit:');
  75.         Readln(PathToDriver);
  76.         Writeln;
  77.       end
  78.       else
  79.         Halt(1);                          { Some other error: terminate }
  80.     end;
  81.   until ErrorCode = grOK;
  82.   Randomize;                { init random number generator }
  83.   MaxColor := GetMaxColor;  { Get the maximum allowable drawing color }
  84.   MaxX := GetMaxX;          { Get screen resolution values }
  85.   MaxY := GetMaxY;
  86. end; { Initialize }
  87.  
  88.  
  89.  
  90.  
  91. begin
  92. end.
  93.